<template>
  <div class="hello" align="center">
    <h1>{{ msg }}</h1>
    
    <button @click="getData">get跨域请求</button>
    <table>
      <tr v-for="item in items" :key="item.title">
        <td>{{item.title}}</td>
      </tr>
    </table>
  </div>
</template>

<script>
export default {
  name: 'Data',
  data () {
    return {
      msg: 'get 和post 跨域请求数据',
      items:[]
    }
  },
  methods:{
    getData:function(){
      //var url = this.HOST+"/movie/top250";
      this.$axios.get("/api/movie/top250",
      {params:{count:10,
               start:0}
      }).then(response =>{
         console.log(response.data);
         this.items = response.data.subjects
      }).catch(error =>{
         console.log(error);
      });
    }
    // post 跨域请求 没做


  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
